#include "./language/language.h"

static SystemLanguage_e sg_eSystemLanguage = SYSTEM_LANGUAGE_CHINESE;

const char *(sg_kSystemLanguage[TEXT_ALL])[SYSTEM_LANGUAGE_ALL] =
{
    [TEXT_MAIN_MENU] = {"主菜单", "Main Menu"},
    [TEXT_FUNCTION_SELECT] = {"功能选择", "Func Select"},
    
//    [TEXT_CHANNEL1_OUTPUT] = {"通道1输出", "Channel 1 Output"},
//    [TEXT_CHANNEL2_OUTPUT] = {"通道2输出", "Channel 2 Output"},
//    [TEXT_CHANNEL3_OUTPUT] = {"通道3输出", "Channel 3 Output"},
//    [TEXT_CHANNEL4_OUTPUT] = {"通道4输出", "Channel 4 Output"},
//    [TEXT_CHANNEL5_OUTPUT] = {"通道5输出", "Channel 5 Output"},
//    [TEXT_CHANNEL6_OUTPUT] = {"通道6输出", "Channel 6 Output"},
    [TEXT_VALUE_ADJUST_MENU] = {"值调整", "Value Adjust"},
    
    /* 通道输出调整菜单文本 */
    [TEXT_CHANNEL1_VOLTAGE] = {"通道1电压", "Channel 1 Voltage"},
    [TEXT_CHANNEL2_VOLTAGE] = {"通道2电压", "Channel 2 Voltage"},
    [TEXT_CHANNEL3_VOLTAGE] = {"通道3电压", "Channel 3 Voltage"},
    [TEXT_CHANNEL4_VOLTAGE] = {"通道4电压", "Channel 4 Voltage"},
    [TEXT_CHANNEL5_CURRENT] = {"通道5电流", "Channel 5 Current"},
    [TEXT_NEEDLE_VALVE_OPENING] = {"针阀开度", "Needle Valve Opening"},
    [TEXT_CHANNEL6_CURRENT] = {"通道6电流", "Channel 6 Current"},
    [TEXT_CHANNEL7_CURRENT] = {"通道7电流", "Channel 7 Current"},
    [TEXT_CHANNEL8_CURRENT] = {"通道8电流", "Channel 8 Current"},

    [TEXT_PWM_SETTING] = {"PWM 设定", "PWM Setting"},
    [TEXT_FREQUENCE_MENU] = {"频率", "Fre"},
    [TEXT_DUTY_MENU] = {"占空比", "Duty"},

    [TEXT_SINE_WAVE_SETTING] = {"正弦波", "Sine Wave"},
    [TEXT_SINEWAVE_FREQ_MENU] = {"频率", "Freq"},
    [TEXT_SINEWAVE_AMP_MENU] = {"幅值", "Amp"},
    [TEXT_SINEWAVE_PHASE_MENU] = {"相位", "Phase"},

    [TEXT_DISPLAY_SETTING] = {"显示设定", "Display Setting"},
    [TEXT_DIRECTION] = {"屏幕方向", "Direction"},
    [TEXT_ROTATE_0] = {"0度", "0°"},
    [TEXT_ROTATE_90] = {"90度", "90°"},
    [TEXT_ROTATE_180] = {"180度", "180°"},
    [TEXT_ROTATE_270] = {"270度", "270°"},
    [TEXT_BRIGHTNESS] = {"屏幕亮度", "Brightness"},
    [TEXT_BRIGHTNESS_20] = {"亮度 20%", "Bright 20%"},
    [TEXT_BRIGHTNESS_40] = {"亮度 40%", "Bright 40%"},
    [TEXT_BRIGHTNESS_60] = {"亮度 60%", "Bright 60%"},
    [TEXT_BRIGHTNESS_80] = {"亮度 80%", "Bright 80%"},
    [TEXT_BRIGHTNESS_100] = {"亮度100%", "Bright 100%"},
    [TEXT_LANGUAGE] = {"语言", "Language"},
    [TEXT_CHINESE] = {"中文", "Chinese"},
    [TEXT_ENGLISH] = {"英文", "English"},

    [TEXT_RESET_DEFAULT] = {"恢复默认", "Reset Default"},
    [TEXT_BACK] = {"返回", "Back"},
    [TEXT_DS18B20_TEMP] = {"DS18B20", "DS18B20"},
    [TEXT_DHT11_TEMP_HUMI] = {"DHT11", "DHT11"},
};

void set_language(SystemLanguage_e lang)
{
    if (lang < SYSTEM_LANGUAGE_ALL)
    {
        sg_eSystemLanguage = lang;
    }
}


const char *get_text(TextId_e id)
{
    static const char *pszNullString = "N/A";

    if (id < TEXT_ALL)
    {
        return sg_kSystemLanguage[id][sg_eSystemLanguage];
    }

    return pszNullString; /* 未找到对应的文本 */
}

const char *get_text_by_language(SystemLanguage_e lang, TextId_e id)
{
    static const char *pszNullString = "N/A";

    if (id < TEXT_ALL)
    {
        return sg_kSystemLanguage[id][lang];
    }

    return pszNullString; /* 未找到对应的文本 */
}
